home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------------------
- | FILE NAME: DataSize.h
- |
- | DOCUMENT: [1033.0]
- |
- | PURPOSE: To isolate and define compiler-dependent conventions so that source
- | code can be objectively defined and easily ported.
- |
- | DESCRIPTION:
- |
- | The 8-bit 'Byte' is taken as the basic unit of storage.
- |
- | Edit the 'typedef' statements in this file so that they
- | are true of your compiler.
- |
- | To avoid ambiguity, use the types defined in this
- | file in place of the systematically ambiguous types:
- | 'int', 'short', 'long', 'void' etc.
- |
- | NOTE:
- |
- | HISTORY: 11.08.93 by Lee Malone
- |----------------------------------------------------------------------------- */
-
- #ifndef _DATASIZE_H_
- #define _DATASIZE_H_
-
- /*
- For 'Think C':---------------------------------------------------------------
-
- 'Byte' is already defined by 'Think C' for the Pascal interface as
- being 1 byte long in 'struct' declarations, but is a
- 'short' (2 bytes) when passed as an argument.
-
- Use 'Byte' in structs or as local variables but DON'T pass a 'Byte'
- as a parameter to another procedure: an error will result. Use the 'Pair'
- type instead to pass byte-size data.
-
- Also make sure all declarations are of the new form to
- avoid promotion conflicts. See p.206 "Think C 5.0 User manual".
-
- For most other compilers:----------------------------------------------------
- Move the following 2 lines outside of this comment block:
- typedef unsigned char Byte;
- typedef char SignedByte;
- */
- typedef unsigned char Byte;
- typedef char SignedByte;
-
- typedef unsigned short Pair; /* 2 adjacent bytes */
- typedef unsigned long Quad; /* 4 adjacent bytes */
-
- /*
- The 'int' type is ambiguous: it may be 2 or 4 bytes long.
- Use 'SignedPair' instead of 'int' if you want a 16-bit integer.
- Use 'SignedQuad' instead of 'int' if you want a 32-bit integer.
- See p.198 "Think C User manual".
- */
-
- typedef short SignedPair; /* range: +/- 32,768 */
- typedef long SignedQuad; /* range: +/- 2,147,483,647 */
-
- typedef SignedByte String;
-
- /* For factual tests: */
- typedef SignedPair Truth; /*
- SignedPair used to avoid
- alignment errors in structures and
- to allow 'Truth' values to be formed
- from arithmetic operations without
- casting.
- */
- #define True 1
- #define False 0
-
- /* Comparison values are interpreted as follows:
-
- Given two values, A and B, in which A is the left-most
- parameter of a comparison procedure:
-
- SomeComparisonProcedure(A,B);
-
- Comparison Value Condition
- 0 if A = B.
- positive number if A > B.
- negative number if A < B.
-
- Comparison values are used for searching and sorting
- procedures.
- */
- typedef SignedQuad Comparison;
-
- /* The 'void' type is ambiguous. Use the following instead: */
- #define Anything void
- #define Nothing void
-
- typedef Anything *AddressOfAnything;
- typedef Byte *AddressOfByte;
- typedef Pair *AddressOfPair;
- typedef Quad *AddressOfQuad;
- typedef SignedByte *AddressOfSignedByte;
- typedef SignedPair *AddressOfSignedPair;
- typedef SignedQuad *AddressOfSignedQuad;
- typedef String *AddressOfString;
- typedef Truth *AddressOfTruth;
-
- typedef unsigned char **AddressOfAddressOfByte;
- typedef String **AddressOfAddressOfString;
-
- typedef Anything (*AddressOfAnyProcedure)();
- typedef Byte (*AddressOfByteProcedure)();
- typedef Comparison (*AddressOfComparisonProcedure)();
- typedef Pair (*AddressOfPairProcedure)();
- typedef Quad (*AddressOfQuadProcedure)();
- typedef SignedPair (*AddressOfSignedPairProcedure)();
- typedef SignedQuad (*AddressOfSignedQuadProcedure)();
- typedef Truth (*AddressOfTruthProcedure)();
-
- /* Define the procedures that manage dynamic memory. */
- #define FreeMemory(a) free(a)
- #define AllocateMemory(a) malloc(a)
-
- #endif /* _DATASIZE_H_ */
-
-